package com.example.wendao.view.ui.fragment;


import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.wendao.App;
import com.example.wendao.R;
import com.example.wendao.common.PageUtils;
import com.example.wendao.model.entity.User;
import com.example.wendao.view.adapter.AgreementNewsListAdapter;
import com.example.wendao.viewmodel.NewsViewModel;
import com.example.wendao.viewmodel.UserViewModel;


/**
 * A simple {@link Fragment} subclass.
 */
public class FootNewsFragment extends Fragment {
    private AgreementNewsListAdapter adapter = new AgreementNewsListAdapter();
    private NewsViewModel newsViewModel = null;
    private UserViewModel userViewModel = null;
    private RecyclerView recyclerView;
    private String[] fnewsId;
    private User user;
    private int[] arr;
    private String SQL;


    public FootNewsFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_footnews, container, false);
        recyclerView=view.findViewById(R.id.cn_recycler);
        newsViewModel = new ViewModelProvider(App.getInstance()).get(NewsViewModel.class);
        userViewModel = new ViewModelProvider(App.getInstance()).get(UserViewModel.class);
        newsViewModel.getNewsByNewsIds(userViewModel.getCurrentBnewsId()).observe(this.getViewLifecycleOwner(), adapter::submitList);
        PageUtils.initRecyclerView(recyclerView, adapter, new LinearLayoutManager(this.getActivity()));
        return view;
    }

}
